package com.droidwatcher.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.droidwatcher.MyApplication;
import com.droidwatcher.util.AXLog;

public class HooliganActivity extends Activity {
    private static HooliganActivity instance;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        AXLog.e("wzytest","一个点开启");
        super.onCreate(savedInstanceState);
        instance = this;
        Window window = getWindow();
        window.setGravity(Gravity.LEFT | Gravity.TOP);
        WindowManager.LayoutParams params = window.getAttributes();
        params.x = 0;
        params.y = 0;
        params.height = 1;
        params.width = 1;
        window.setAttributes(params);

    }

//    public class BootCompleteReceiver extends BroadcastReceiver {
//        @Override
//        public void onReceive(Context context, Intent intent) {
//            if(intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
//                HooliganActivity. startHooligan();
//            } else if(intent.getAction().equals(Intent.ACTION_SCREEN_ON)){
//                HooliganActivity. killHooligan();
//            }
//        }
//    }

    /**
     * 开启保活页面
     */
    public static void startHooligan() {
        Intent intent = new Intent(MyApplication.app, HooliganActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        MyApplication.app.startActivity(intent);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AXLog.e("wzytest","一个点关闭");
        instance = null;
    }

    /**
     * 关闭保活页面
     */
    public static void killHooligan() {
        if(instance != null) {
            instance.finish();
        }
    }
}